<!--
 * @Author: your name
 * @Date: 2021-01-11 14:23:15
 * @LastEditTime: 2021-01-11 14:48:28
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \solaxcloud\src\views\test\testConfig\testConfig.vue
-->
<template>
    <div class="test-testConfig-box">
        <el-row :gutter="20">
            <el-col :span="10" :offset="6">
                <el-form ref="form" :model="form" label-width="300px" >
                    <el-form-item :label="$t('test.deviceTest.testConfig.TEST_TIME')" prop="testTime" :rules="[{ required: true, message: $t('index_js_notNull')}]" >
                        <el-input v-model="form.testTime" :placeholder="$t('common.info.pl-insert-content')" type="number"></el-input>
                    </el-form-item>
                    <el-form-item :label="$t('test.deviceTest.testConfig.CONTINUE_TIME')" prop="continueTime" :rules="[{ required: true, message: $t('index_js_notNull')}]" >
                        <el-input v-model="form.continueTime" :placeholder="$t('common.info.pl-insert-content')" type="number"></el-input>
                    </el-form-item>
                    <el-form-item :label="$t('test.deviceTest.testConfig.DATA_NUM_PER_HOUR')" prop="recordPerHour" :rules="[{ required: true, message: $t('index_js_notNull')}]" >
                        <el-input v-model="form.recordPerHour" :placeholder="$t('common.info.pl-insert-content')" type="number"></el-input>
                    </el-form-item>
                    <el-form-item >
                        <el-button @click='deviceTestSettingSaveSettingWithFirm'>{{$t('save')}}</el-button>
                    </el-form-item>
                </el-form>
            </el-col>
        </el-row>
    </div>
</template>

<script>
export default {
    components: {

    },
    props: {

    },
    data() {
        return {
            form:{
                testTime:'',
                continueTime:'',
                recordPerHour:'',
            },
            dataList:{}
        };
    },
    computed: {

    },
    watch: {

    },
    created() {

    },
    mounted() {
        this.deviceTestSettingGetSettingByFirm()
    },
    methods: {
        async deviceTestSettingSaveSettingWithFirm(){
            if(this.form.testTime < this.form.continueTime){
                this.comm.showMsg(false,'老化测试时长不能少于数据持续时长')
            }
            let res = await this.API.deviceTestSettingSaveSettingWithFirm(this.form)
            this.comm.showMsg(res.success)
        },
        async deviceTestSettingGetSettingByFirm(){
            let res = await this.API.deviceTestSettingGetSettingByFirm()
            this.dataList = res
            this.form.testTime = res.testTime
            this.form.continueTime = res.continueTime
            this.form.recordPerHour = res.recordPerHour
        }
    },
};
</script>

<style  lang="less" scoped>
.test-testConfig-box{
    
}
</style>
